﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HighDiveAdmin.Resources;

namespace HighDiveAdmin.Engine
{
    /// <summary>
    /// Dataclass that holds data for a dive. Difficulty i automatically calculated inside the constructor
    /// </summary>
    public class Dive
    {
        #region Properties
        /// <summary>
        /// DatabasId
        /// </summary>
        public int DbId { get; set; }
        public Person Diver { get; set; }
        public string DiveCode { get; set; }
        public double Difficulty { get; set; }
        public int DiveNumber { get; set; }
        public double DiveHeight { get; set; }
        public double?[] JudgeScore { get; set; }
        public double? TotalScore { get; set; }

        #endregion

        #region Constructors
        public Dive() { }

        /// <summary>Creates a new Dive</summary>
        /// <param name="diver">The person that performs the dive</param>
        /// <param name="diveCode">The divecode for the dive</param>
        /// <param name="diveNumber">The dive number</param>
        /// <param name="diveHeight">The height the dive is performed from</param>
        public Dive(Person diver, string diveCode, int diveNumber, int diveHeight)
        {
            Diver = diver;
            DiveCode = diveCode;
            DiveNumber = diveNumber;
            DiveHeight = diveHeight;
            if (Difficulty == 0)
                Difficulty = DiveCodeDifficultyCalculator.Instance.GetDifficulty(diveCode, diveHeight);
            DbId = -1;
            JudgeScore = null;
            TotalScore = -1;
        }

        #endregion
    }
}
